package com.IC.base.service.impl;

import com.IC.base.mapper.ActualVehicleMapper;
import com.IC.base.service.ActualVehicleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.IC.domain.dto.ActualVehicleDTO;
import com.IC.domain.po.ActualVehiclePO;
import com.IC.domain.vo.ActualVehicleVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class ActualVehicleServiceImpl extends ServiceImpl<ActualVehicleMapper, ActualVehiclePO> implements ActualVehicleService {

    @Autowired
    private ActualVehicleMapper actualVehicleMapper;

    @Autowired
    private KafkaTemplate<Object, Object> kafkaTemplate;

    @Override
    public PageInfo<ActualVehicleVO> findlist(ActualVehicleDTO actualVehicleDTO) {
        PageHelper.startPage(actualVehicleDTO.getPageNum(), actualVehicleDTO.getPageSize());
        List<ActualVehicleVO> list = actualVehicleMapper.findList(actualVehicleDTO);
        PageInfo<ActualVehicleVO> actualVehiclePOPageInfo = new PageInfo<>(list);
        return actualVehiclePOPageInfo;
    }

    @Override
    public List<ActualVehicleVO> selectlist() {
        return actualVehicleMapper.selectlist();
    }

    @Override
    @Transactional
    public List<ActualVehicleVO> all() {
        List<ActualVehicleVO> list = actualVehicleMapper.findList(null);
        kafkaTemplate.send("vehicle", list);
        return list;
    }

}
